<?php
$str = current_url();
$arr = array("/price/asc", "/price/desc");
$url = str_replace($arr,'',$str);
?>
<script>
    var CURRENT_URL = '<?PHP echo $url ; ?>';
//    onchange="window.location=CURRENT_URL+'/'+this.value"
    
</script>
<div class="list-content">
    <div class="title-content">
        <div class="title-name">
            <h2>
                <img src="<?php echo base_url("public/template/frontend/images") ?>/title-pro.png" alt="title">
                <?php echo isset($cat->name) ? $cat->name : "Sản phẩm"; ?>
            </h2>
            <span>Hiện có <?php echo count($listpro); ?> sản phẩm</span>
        </div>
        <div class="order-by">
            <select onchange="location.href= CURRENT_URL+ '/price/' + this.value">
                <option>Sắp xếp sản phẩm</option>
                <option value="asc" id="priceAsc">Giá tăng dần</option>
                <option value="desc" id="priceDesc">Giá giảm dần</option>
            </select>
        </div>                           
    </div><!--title-content-->
    <div class="clear-both"></div>
    <div class="main-content">
        <?php
        if (isset($listpro) && count($listpro))
            foreach ($listpro as $p) {
                ?>
                <div class="pro_item">
                    <div class="item_img">
                        <a href="<?php echo base_url("frontend/product/detail") . '/' . $p->id; ?>"><img src="<?php echo base_url($p->img); ?>" alt=""></a>
                    </div>
                    <div class="item_name">
                        <a href="<?php echo base_url("frontend/product/detail") . '/' . $p->id; ?>" title="<?php echo $p->name; ?>"><?php echo word_limiter(ucfirst($p->name), 6); ?></a>
                    </div>
                    <div class="item_price">
                        <span><?php echo number_format($p->price); ?> đ</span>
                    </div>
                </div>
                <?php
            }
        ?>

    </div><!--main-content-->
    <div class="clear-both"></div>   
    <?php if (isset($paging)) echo $paging; ?>
</div><!--list-content-->